package reflect;

/**
 * JDK5之后推出了一个特性:变长参数
 */
public class ArgsDemo {
    public static void main(String[] args) {
        dosome();
        dosome("1");
        dosome("1","2");
        dosome("1","2","2","2","2","2","2","2","2","2","2","2","2");

//        编译后，所有参数都为数组元素
//        dosome(new String[]{});
//        dosome(new String[]{"1"});
//        dosome(new String[]{"1","2"});
//        dosome(new String[]{"1","2","2","2","2","2","2","2","2","2","2","2","2"});
    }

//    public static void dosome(String[] s){//编译后可变长参数为数组类型
    /*
        可变长参数的要求是:必须为一个方法的最后一个参数
     */
    public static void dosome(String... s){
        System.out.println(s.length);
    }

}





